<?php

/** 
* 
* 
* by:南宁火蝶科技有限公司 http:///www.HdsysCms.com
* 声明:本系统禁止用二次开发、侵犯HdsysCms著作和除去HdsysCms进行售卖,如发现将追究一切权利,模版制作属于自己所得可以通过本系统对外开发模版获取收益!
* 
* 2019年第一版本发布 - 到2023.9.1开源使用! 
* php混淆工具:phpencry.wbox.top
* 
* 注意防骗:@HdsysCms 官方没授权任何个人机构合作,唯一收款抬头:《南宁火蝶科技有限公司》和官网显示客服唯一渠道客服,其它渠道以HdsysCms名义行为均骗子!
*
*/
	

defined('HDSYS_SET') or die("" . 'Not,This File Not Can in Ie Open');
class templates
{
public $intelligence_templates_dir='';
public $intelligence_FileTemplatescContent='';
public $intelligence_db='';
public function __construct()
{
$this->intelligence_db=bs_lib::load_libhdsys_class("" . 'db');
$this->intelligence_templates_dir=intelligence_get_templates_dir();
}
public function GetTemplatesFile($param_dir_file, &$param_back)
{
$param_back='200';
$param_dir_file=safe_replace_file($param_dir_file);
$param_name=$param_dir_file . "" . '.hdsys.php';
$param_File_Name=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . $param_name;
if (!file_exists($param_File_Name)) {
$param_back='404';
$param_File_404=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/' . '404' . '.hdsys.php';
if (file_exists($param_File_404)) {
$param_File_Data=file_get_contents($param_File_404);
$param_File_Data=call_my_str_replace('{$FILE_NAME}', $param_File_Name, $param_File_Data);
return $param_File_Data;
}
if (!preg_match('/^[a-zA-Z0-9\._-]+$/', $param_dir_file, $param_daata)) {
header('HTTP/1.1 404 Not Found');
return '<script> window.CODE="1000"  </script> <a id="maginfo" style="color: #CC5522;" >访问地址错误404:' . substr(getsysurl(), 0, -1) . $_SERVER['REQUEST_URI'] . ' ' . time() . '<a>';
return (0);
}
$param_File_Data=call_my_str_replace(HDSYS_DIR_SYS, $param_File_Name, $param_File_Name);
if (get_session_value('DIV_MEIN')==1) {
return '<script> window.CODE="1000"  </script> <a id="maginfo" style="color: #CC5522;" >[可视化开发模式 模版不存在:' . "{$param_File_Name}" . '] ' . time() . '<a>';
} else {
return '<script> window.CODE="1000"  </script> <a id="maginfo" style="color: #CC5522;" >[模版不存在:' . "{$param_File_Name}" . '] ' . time() . '<a>';
}
}
#无需生成,判断是否需要生成
$param_re=call_my_push_templates_html($param_name, $this->intelligence_templates_dir);
if ($param_re !='') {
echo '<a style="color: #CC5522;" >[' . $param_re . '] ' . time() . '<a>';
exit;
}
$param_File_Data=file_get_contents($param_File_Name);
return $param_File_Data;
}
public function GetPublicFile($param_dir_file)
{
$param_dir_file=safe_replace_file($param_dir_file);
$param_File_Name=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/Public/' . $param_dir_file . '.php';
if (!is_file($param_File_Name)) {
return '<include file="' . $param_dir_file . '" msg="模版不存在" />';
}
$param_File_Data=file_get_contents($param_File_Name);
return $param_File_Data;
}
public function Compiler($param_dir_file,$param_url_name, $data)
{
if($param_url_name==''){
$param_url_name='index';
}
$this->intelligence_FileTemplatescContent=$this->GetTemplatesFile($param_dir_file, $param_back);
$this->intelligence_getinclude();
$this->intelligence_getinclude();
$this->intelligence_getinclude();
$this->intelligence_getconfig();
$this->intelligence_dataStr($data, 1);
$this->intelligence_getconfig();
$this->intelligence_dataStr($data, 0);
$this->intelligence_getadvertisement();
$this->intelligence_new_navigation($data);
$this->intelligence_advertisementAs();
$this->intelligence_exhibitionAs();
$this->intelligence_arrexhibition();
$this->intelligence_columnAs($data);
$this->intelligence_contentAs($data);
$this->intelligence_prevnext($data);
$this->intelligence_basic1($param_url_name);
$this->intelligence_basic2();
$this->intelligence_basic3();
$this->intelligence_div_mein();
$this->intelligence_js_css();
$param_DIV_MEIN=(int)get_session_value('DIV_MEIN');
if ($param_DIV_MEIN==1) {
$param_arr=call_my_is_visualization($this->intelligence_templates_dir);
if ($param_arr['code']==2) {
$param_getsysurl=getcdnurlhost();
$param_file=$param_dir_file . "" . '.hdsys.php';
$param_time=time();
$param_html="\n<link rel='stylesheet' href='{$param_getsysurl}/DivTemplates/Hdsys-Div.css?v={$param_time}' media='all'>\n";
$param_admin_dir=get_session_value('DIV_ADMIN_URL');
$param_html .="<script> window.hdsys_config={\"file\":\"$param_file\",\"dir\":\"{$this->intelligence_templates_dir}\",\"host\":\"{$param_getsysurl}\",\"admin_dir\":\"{$param_admin_dir}\"}  </script>\n";
if ($param_back==200) {
set_session_value('DIV_MEIN_file', $param_file);
}
set_session_value('DIV_MEIN_dir', $this->intelligence_templates_dir);
$param_html .="<link rel='stylesheet' href='{$param_getsysurl}/admin/layui/css/layui.css' media='all'>\n";
$param_html .="<script src='{$param_getsysurl}/admin/layui/layui.js'></script>\n";
$param_html .="<script src='{$param_getsysurl}/DivTemplates/Hdsys-Div.js'></script>\n";
$this->intelligence_FileTemplatescContent .=$param_html;
}
}
if ($this->intelligence_FileTemplatescContent=='') {
$param_File_Name=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/'  . $param_dir_file . "" . '.hdsys.php';
echo '<a style="color: #CC5522;" >[模版没有内容缓存写入失败:' . $param_File_Name . '] ' . time() . '<a>';
exit;
}
$param_file_cache=HDSYS_DIR_SYS . 'cache/templates.' . call_my_md5(getsysurl() . $param_dir_file . $_SERVER["" . 'REQUEST_URI']) . '.php';
$param_tmp=file_put_contents($param_file_cache, $this->intelligence_FileTemplatescContent);
if (!$param_tmp) {
echo '<a style="color: #CC5522;" >[缓存写入失败:WEB根目录cache 目录请设置777可写属性] ' . time() . '<a>';
exit;
}
return $param_file_cache;
}
public function intelligence_getadvertisement()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$advertisement\.(.*?)\.(.*?)\}#',
function ($param_matches) {
$param_File=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/modular/' . $param_matches[1] . '.*.modular.php';
$param_File_ARRAY=glob($param_File);
if (isset($param_File_ARRAY[0])) {
$param_arr=include($param_File_ARRAY[0]);
if (isset($param_arr[$param_matches[2]])) {
if ($param_matches[2]=='imges' or $param_matches[2]=='eimges') {
$param_val=$param_arr[$param_matches[2]];
$param_val=str_replace('{__URL__}', getsysurl(), $param_val);
$param_val=str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);
return $param_val;
} else {
return $param_arr[$param_matches[2]];
}
} else {
return '!~' . $param_matches[2] . '~!' . $param_matches[0];;
}
} else {
return '!~' . $param_matches[0];
}
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_js_css()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/<script([a-zA-Z0-9_=\s\'"]+)>\s(.*?)\s<\/script>/is',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[1]);
if (isset($param_array['long']) and $param_array['long']=='file') {
$param_src_md5=call_my_md5($param_matches[2]);
$param_file="cache/hdsyscms-{$param_src_md5}.js";
@file_put_contents(HDSYS_DIR_SYS . $param_file, $param_matches[2]);
$param_url=getsysurl() . $param_file . '?t=' . call_my_time();
return "<script src='{$param_url}'></script>";
}
return $param_matches[0];
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/<style([a-zA-Z0-9_=\s\'\"]+)>\s(.*?)\s<\/style>/is',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[1]);
if (isset($param_array['long']) and $param_array['long']=='file') {
$param_src_md5=call_my_md5($param_matches[2]);
$param_file="cache/hdsyscms-{$param_src_md5}.css";
@file_put_contents(HDSYS_DIR_SYS . $param_file, $param_matches[2]);
$param_url=getsysurl() . $param_file . '?t=' . call_my_time();
if (isset($param_array['rel']) and $param_array['rel'] !='') {
$param_rel="rel=\"{$param_array['rel']}\"";
} else {
$param_rel="rel=\"stylesheet\"";
}
return "<link href=\"{$param_url}\" rel=\"stylesheet\"  >";
}
return $param_matches[0];
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_div_mein()
{
$param_DIV_MEIN=(int)get_session_value('DIV_MEIN');
$param_patten=[
'#<hdsysinfo(.*?)/>#',
'#<hdsyspage(.*?)/>#'
];
$translation=[
'',
''
];
$this->intelligence_FileTemplatescContent=preg_replace($param_patten, $translation, $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=preg_replace("|\s*\n+|", PHP_EOL, str_replace(array("\r\n", "\r"), "\n", $this->intelligence_FileTemplatescContent));
$this->intelligence_FileTemplatescContent=preg_replace_callback(
"/([\w\W]*\n+)/iU",
function ($matches) {
if (substr(trim($matches[0]), 0, 2)=='//') {
return '';
} else {
return trim($matches[0]) . "\n";
}
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_basic1($param_url_name)
{
#设置缩略图替换
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$([a-zA-Z0-9_]+)\.graph\}#',
function ($param_matches) {
return '<?php echo GetImgesUrl($' . $param_matches[1] . '["graph"]);   ?>';
},
$this->intelligence_FileTemplatescContent
);
$patten=[
'#\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)([\s]+|)\)#',
'#\(\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\)#',
'#\({\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}\)#',
'#\{(else if|elseif) (.*?)\}#',
'#\{else\}#',
'#\{\/(foreach|if)}#',
'#\{\\^(k|v)\}#',
'#\{foreach \$(.*?)\.(.*?) as (.*?) \}#',
'#\{!(.*?)\}#',
'#\{\$([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}#',
'#\{@(.*?)\}#',
'#\{__STATICS__\}#',
'#\{__DOMAIN__\}#',
'#\{__URL__\}#',
'#\{foreach (.*?) as \$(.*?)\}#',
'#\{\$vo\}#',
'#\{php (.*?)\}#',
'#\{if (.*?)\}#',
'#{__URI__}#',
'#{__TEMPLATES__}#',
'#\{\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\}#',
'#\{\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\.([0-9]+)\}#',
'#\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)\.([0-9]+)#',
'#\$([a-zA-Z0-9_]+)\.modules\.([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)#',
'#{__URL_NAME__}#',
'#__URL_NAME__#',
];
$translation=[
'$\\1["\\2"])',
'($\\1["\\2"])',
'($\\1["\\2"])',
'<?php } else if <hdsyscms-kuohao>\\2<hdsyscms-kuohao> { ?>',
'<?php }else { ?>',
'<?php } ?>',
'<?php echo \$\\1?>',
'<?php  foreach<hdsyscms-kuohao> \$\\1["\\2"] as \\3 </hdsyscms-kuohao>{    ?>',
'<?php  \\1;   ?>',
'<hdsyscms-val>\$\\1[\'\\2\']</hdsyscms-val>',
'<?php echo \\1;   ?>',
getsysurl() . 'templates/' . $this->intelligence_templates_dir . '/statics',
getsysurl(),
getsysurl(),
'<?php  foreach<hdsyscms-kuohao> \\1 as $\\2 </hdsyscms-kuohao>{    ?>',
'<?php echo \$vo   ?>',
'<?php  \\1  ?>',
'<?php if <hdsyscms-kuohao>\\1</hdsyscms-kuohao> { ?>',
substr(getsysurl(), 0, -1) . $_SERVER['REQUEST_URI'],
intelligence_get_templates_dir(),
'<?php echo isset(\$\\1["modules"]["\\2"]["\\3"][0])?GetImgesUrl(\$\\1["modules"]["\\2"]["\\3"][0]):""; ?>',
'<?php echo isset(\$\\1["modules"]["\\2"]["\\3"][\\4])?GetImgesUrl(\$\\1["modules"]["\\2"]["\\3"][\\4]):""; ?>',
'$\\1["modules"]["\\2"]["\\3"]["\\4"]',
'$\\1["modules"]["\\2"]["\\3"]',
$param_url_name,
$param_url_name,
];
$this->intelligence_FileTemplatescContent=preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
}
public function intelligence_basic2()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#<\?php (.*?) \?>#',
function ($param_matches) {
$intelligence_Content=$param_matches[0];
$intelligence_Content=preg_replace_callback(
'/\s([a-zA-Z0-9_]+)\((.*?)\)/',
function ($param_matches) {
$param_matches[2]=call_my_str_basic($param_matches[2]);
$param_matches[2]=call_my_str_replace("','", "'<hdsyscms-douhao/>'", $param_matches[2]);
$param_matches[2]=call_my_str_replace('","', '"<hdsyscms-douhao/>"', $param_matches[2]);
$param_matches[2]=preg_replace_callback(
'/\[((.*?)=>(.*?))\](,|$|\s+,)/i',
function ($param_matches) {
$param_matches[0]=call_my_str_replace(',', '<hdsyscms-suzu-douhao/>', $param_matches[0]);
$param_matches[0]=preg_replace('#\](\s+|)<hdsyscms-suzu-douhao/>#', ']\\1,', $param_matches[0]);
return  $param_matches[0];
},
$param_matches[2]
);
$param_ex=explode(',', $param_matches[2]);
$param_new='';
$param_i=0;
foreach ($param_ex as $param_v) {
$param_i++;
$param_v=call_my_newpara(trim($param_v));
if (stripos($param_v, '"') > -1 or stripos($param_v, '"') > -1) {
$param_v=preg_replace('#<hdsyscms-val>(.*?)</hdsyscms-val>#', '{\\1}', $param_v);
}
if (stripos($param_v, '"')==false and stripos($param_v, '"')==false) {
$param_v=preg_replace('#<hdsyscms-val>(.*?)</hdsyscms-val>#', '\\1', $param_v);
}
if (substr($param_v, 0, 1)=='[' and substr($param_v, -1)==']' and $param_v !='' and $param_v !='[]') {
$param_y_i=0;
$para_data=substr($param_v, 1, -1);
$para_data_arr=explode('<hdsyscms-suzu-douhao/>', $para_data);
$param_tmp='';
foreach ($para_data_arr as $param_y) {
$param_y_i++;
$para_data_ex=explode('=>', $param_y);
if (substr($para_data_ex[0], 0, 1) !='"' and substr($para_data_ex[0], -1) !='"' and substr($para_data_ex[0], 0, 1) !="'" and substr($para_data_ex[0], -1) !="'") {
$para_data_ex[0]='"' . $para_data_ex[0] . '"';
}
if (substr($para_data_ex[1], 0, 1) !='"' and substr($para_data_ex[1], -1) !='"' and substr($para_data_ex[1], 0, 1) !="'" and substr($para_data_ex[1], -1) !="'") {
$para_data_ex[1]='"' . $para_data_ex[1] . '"';
}
$param_tmp .=$para_data_ex[0] . '=>' . $para_data_ex[1];
if ($param_y_i < count($para_data_arr)) {
$param_tmp .=',';
}
}
$param_v="[{$param_tmp}]";
}
$param_new .=$param_v;
if ($param_i < count($param_ex)) {
$param_new .=',';
}
}
if (substr($param_matches[0], 0, 1)==' ') {
return " {$param_matches[1]}(" . $param_new . ')';
} else {
return "{$param_matches[1]}(" . $param_new . ')';
}
},
$intelligence_Content
);
return $intelligence_Content;
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_basic3()
{
$GLOBALS['replace_arr']=array();
$this->intelligence_FileTemplatescContent=preg_replace_callback(
DIV_HDSYSCMS_VALUE,
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
if (!isset($param_array['val'])) {
$param_array['val']='';
}
if (isset($param_array['name']) and $param_array['name'] !='') {
$GLOBALS['replace_arr'][]=array('name'=> $param_array['name'], 'val'=> $param_array['val']);
}
return $param_array['val'];
},
$this->intelligence_FileTemplatescContent
);
foreach ($GLOBALS['replace_arr'] as $param_v) {
$this->intelligence_FileTemplatescContent=str_replace("{{$param_v['name']}}", $param_v['val'], 	$this->intelligence_FileTemplatescContent);
}
unset($GLOBALS['replace_arr']);
$patten=[
'#<hdsyscms-val>(.*?)</hdsyscms-val>#',
'#<hdsyscms-douhao/>#',
];
$translation=[
'<?php echo @\\1  ?>',
',',
];
$this->intelligence_FileTemplatescContent=preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
$patten=[
'#\{\$v\}#',
];
$translation=[
bs_lib::get_configs_value('setup', 'dbug')==0 ? filemtime(HDSYS_DIR_SYS . 'cache/configs') : time(),
];
$this->intelligence_FileTemplatescContent=preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#<hdsyscms-kuohao>(.*?)</hdsyscms-kuohao>#',
function ($param_matches) {
$param_matches[1]=call_my_str_basic_kuohao($param_matches[1]);
return "( {$param_matches[1]}  )";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#<hdsyscms-dakuohao>(.*?)</hdsyscms-dakuohao>#',
function ($param_matches) {
$param_matches[1]=call_my_str_basic_kuohao($param_matches[1]);
return "{{$param_matches[1]}}";
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_getinclude()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{include:(.*?)\}#',
function ($param_matches) {
return $this->GetPublicFile($param_matches[1]);
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\<include(.*?)>#',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[1]);
$param_file=call_my_GetArray($param_array, 'file', '');
return $this->GetPublicFile($param_file);
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_getconfig()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$config\.(.*?)\.(.*?)\}#',
function ($param_matches) {
return bs_lib::get_configs_value($param_matches[1], $param_matches[2]);
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\$config\.([a-z_]+)\.([a-z_]+)#',
function ($param_matches) {
return 'config("' . $param_matches[1] . '","' . $param_matches[2] . '")';
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_new_navigation()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/([{|<])navigation([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
$param_File_dir=$this->GetnavigationCacheArray($param_array);
return '<?php ' . call_my_var(call_my_GetArray($param_array, 'for', 'navigation')) . "=include('{$param_File_dir}'); \n    \$loop=0;    \n foreach( " . call_my_var(call_my_GetArray($param_array, 'for', 'navigation')) . " as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){ \$loop++; ?>";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=call_my_str_replace(array('</navigation>', '{/navigation}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
}
public function str_inner($param_strdata, $param_type='e')
{
$param_strdata=call_my_str_replace('../upfiles/', getsysurl() . 'upfiles/', $param_strdata);
$param_sql="SELECT * FROM `hdsys_inner`";
$param_db_array_value=$this->intelligence_db->intelligence_query($param_sql);
$param_while_array_list_all=array();
while ($param_value=$this->intelligence_db->intelligence_assoc($param_db_array_value)) {
$param_strdata=$this->intelligence_str_replace_once($param_value[$param_type . 'name'], "<a target='_blank' href='{$param_value[$param_type . 'url']}'>{$param_value[$param_type . 'name']}</a>", $param_strdata);
}
return $param_strdata;
}
public function intelligence_str_replace_once($param_needle, $param_replace, $param_haystack)
{
$param_pos=strpos($param_haystack, $param_needle);
if ($param_pos===false) {
return $param_haystack;
}
return substr_replace($param_haystack, $param_replace, $param_pos, strlen($param_needle));
}
public function intelligence_dataStr($data, $param_qt=0)
{
$GLOBALS['dataStr']=$data;
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$data\.([a-zA-Z0-9_]+)\}#',
function ($param_matches) {
if ($param_matches[1]=='content' AND isset($GLOBALS['dataStr'][$param_matches[1]])) {
$GLOBALS['dataStr'][$param_matches[1]]=$this->str_inner($GLOBALS['dataStr'][$param_matches[1]], '');
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
return '<?php echo base64_decode("' . base64_encode($GLOBALS['dataStr'][$param_matches[1]]) . '"); ?>';
}
if ($param_matches[1]=='econtent' AND isset($GLOBALS['dataStr'][$param_matches[1]])) {
$GLOBALS['dataStr'][$param_matches[1]]=$this->str_inner($GLOBALS['dataStr'][$param_matches[1]], 'e');
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('"../upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('\'../upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('"/upfiles/attached/image/', '"' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('\'/upfiles/attached/image/', '\'' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('|../upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
$GLOBALS['dataStr'][$param_matches[1]]=str_replace('|/upfiles/attached/image/', '|' . getsysurl() . 'upfiles/attached/image/', $GLOBALS['dataStr'][$param_matches[1]]);
return '<?php echo base64_decode("' . base64_encode($GLOBALS['dataStr'][$param_matches[1]]) . '"); ?>';
}
$param_data=isset($GLOBALS['dataStr'][$param_matches[1]]) ? $GLOBALS['dataStr'][$param_matches[1]] : '';
if ($param_matches[1]=='pid') {
$param_data=call_my_str_replace(',', '|', $param_data);
}
if ($param_matches[1]=='seotitle') {
if ($param_data=='') {
$param_data=$GLOBALS['dataStr']['name'] . ' - {$config.setup.name}';
}
} elseif ($param_matches[1]=='eseotitle') {
if ($param_data=='') {
$param_data=$GLOBALS['dataStr']['ename'] . ' - {$config.esetup.name}';
}
} elseif ($param_matches[1]=='seokeywords') {
if ($param_data=='') {
$param_data='{$data.name},{$config.setup.seokeywords}';
}
} elseif ($param_matches[1]=='seodescription') {
if ($param_data=='') {
$param_data='{$config.setup.seodescription}';
}
} elseif ($param_matches[1]=='eseokeywords') {
if ($param_data=='') {
$param_data='{$data.ename},{$config.esetup.seokeywords}';
}
} elseif ($param_matches[1]=='eseodescription') {
if ($param_data=='') {
$param_data='{$config.esetup.seodescription}';
}
}
$param_data=call_my_str_replace(',', '<hdsyscms-douhao/>', $param_data);
return $param_data;
},
$this->intelligence_FileTemplatescContent
);
if ($param_qt==1) {
return;
}
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$data\.nav\.([0-9_]+)\.([a-zA-Z0-9_]+)\}#',
function ($param_matches) {
return isset($GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]]) ? $GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]] : '';
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\$data\.nav\.([0-9_]+)\.([a-zA-Z0-9_]+)#',
function ($param_matches) {
return isset($GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]]) ? $GLOBALS['dataStr']['nav'][$param_matches[1]][$param_matches[2]] : '';
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\$data\.([a-zA-Z0-9_]+)#',
function ($param_matches) {
if ($param_matches[1]=='modules') {
return $param_matches[0];
}
$param_data=isset($GLOBALS['dataStr'][$param_matches[1]]) ? $GLOBALS['dataStr'][$param_matches[1]] : '';
if ($param_matches[1]=='pid') {
$param_data=call_my_str_replace(',', '|', $param_data);
}
$param_data=call_my_str_replace(',', '<hdsyscms-douhao/>', $param_data);
return $param_data;
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$get\.([a-zA-Z0-9_]+)\}#',
function ($param_matches) {
return set_get($param_matches[1]);
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\$get\.([a-zA-Z0-9_]+)#',
function ($param_matches) {
return set_get($param_matches[1]);
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\$post\.([a-zA-Z0-9_]+)\}#',
function ($param_matches) {
return set_post($param_matches[1]);
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\$post\.([a-zA-Z0-9_]+)#',
function ($param_matches) {
return set_post($param_matches[1]);
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_exhibitionAs()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/([{|<])exhibition([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
$json=call_my_array_code($param_array);
$foreachname="\$e" . call_my_md5($json);
$p=md5($json);
return "<?php \$a{$p}=$json;  {$foreachname}=include(D_Get_Exhibition_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n  \$loop=0;    \n foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){  \$loop++; ?>";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=call_my_str_replace(array('</exhibition>', '{/exhibition}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
}
public function intelligence_arrexhibition()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/([{|<])exquery([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_$]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
$json=call_my_array_code($param_array);
$foreachname=call_my_var(call_my_GetArray($param_array, 'as', 'vo'));
$p=md5($json);
return "<?php	\$a{$p}=$json ;  {$foreachname}=include(D_Get_GetExQuery_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); ?>";
},
$this->intelligence_FileTemplatescContent
);
}
public function intelligence_prevnext($data)
{
if (!isset($data['pid'])) {
return false;
}
if (
stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.url}')==false
and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.name}')==false
and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.url}')==false
and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.name}')==false
and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.prev.ename}')==false
and stripos($this->intelligence_FileTemplatescContent, '{$prevnext.next.ename}')==false
) {
return false;
}
$ColumnName='mysql_prevnext_' . call_my_md5($_SERVER['REQUEST_URI']);
$param_array=$this->GetFileArrayCodeCache($ColumnName);
if ($param_array==false) {
$param_static_url=$data['id'] - 1;
$param_sql="SELECT `id`,`name`,`ename`,`static_url` FROM `hdsys_content`  where `id`='{$param_static_url}' limit 1 ;";
$param_db_array_prev=$this->intelligence_db->intelligence_array($param_sql);
if (!$param_db_array_prev) {
$param_db_array_prev['static_url']='#';
$param_db_array_prev['name']='';
$param_db_array_prev['ename']='';
}
#下
$param_static_url=$data['id'] + 1;
$param_sql="SELECT `id`,`name`,`ename`,`static_url` FROM `hdsys_content`  where 	 `id`='{$param_static_url}'  limit 1 ;";
$param_db_array_next=$this->intelligence_db->intelligence_array($param_sql);
if (!$param_db_array_next) {
$param_db_array_next['static_url']='#';
$param_db_array_next['name']='';
$param_db_array_next['ename']='';
}
$param_while_array_list_all=array();
$param_while_array_list_all['prev']=$param_db_array_prev;
$param_while_array_list_all['next']=$param_db_array_next;
$this->PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
} else {
$param_array=include($param_array);
$param_db_array_prev=$param_array['prev'];
$param_db_array_next=$param_array['next'];
}
$patten=[
'#\{\$prevnext\.prev\.url\}#',
'#\{\$prevnext\.prev\.name\}#',
'#\{\$prevnext\.next\.url\}#',
'#\{\$prevnext\.next\.name\}#',
'#\{\$prevnext\.prev\.ename\}#',
'#\{\$prevnext\.next\.ename\}#',
];
$translation=[
$param_db_array_prev['static_url'],
$param_db_array_prev['name'],
$param_db_array_next['static_url'],
$param_db_array_next['name'],
$param_db_array_prev['ename'],
$param_db_array_next['ename']
];
$this->intelligence_FileTemplatescContent=preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
$patten=[
'#\$prevnext\.prev\.url#',
'#\$prevnext\.prev\.name#',
'#\$prevnext\.next\.url#',
'#\$prevnext\.next\.name#',
];
$translation=[
"'" . $param_db_array_prev['static_url'] . "'",
"'" . $param_db_array_prev['name'] . "'",
"'" . $param_db_array_next['static_url'] . "'",
"'" . $param_db_array_next['name'] . "'"
];
$this->intelligence_FileTemplatescContent=preg_replace($patten, $translation, $this->intelligence_FileTemplatescContent);
}
public function intelligence_columnAs($data)
{
$GLOBALS['data']=$data;
$GLOBALS['columnAs']=0;
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/([{|<])column([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)([}|>])/i',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
$json=call_my_array_code($param_array);
$GLOBALS['jsonarr']=$param_array;
$GLOBALS['columnAs']=1;
$foreachname="\$e" . call_my_md5($json);
$p=md5($json);
return "<?php \$a{$p}=$json; {$foreachname}=include(D_Get_Column_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n  \$loop=0;    \n  foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){   \$loop++;    ?>";
},
$this->intelligence_FileTemplatescContent
);
if ($GLOBALS['columnAs']==0) {
unset($GLOBALS['columnAs']);
return;
}
$this->intelligence_FileTemplatescContent=call_my_str_replace(array('</column>', '{/column}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
}
public function intelligence_contentAs($data)
{
$GLOBALS['contentAs_arr']=array();
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#([{|<])(content|<column)([a-zA-Z0-9_\s]+=([0-9]+|[a-zA-Z0-9_$]+|\"(.*?)\"|\'.*?\'))+(}|\s+}|>|\s+>)#',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
if (isset($param_array['pageas'])) {
$param_array['pageas']=call_my_str_replace('$', '', $param_array['pageas']);
}
$json=call_my_array_code($param_array);
$param_pageas=call_my_GetArray($param_array, 'pageas', '');
if ($param_pageas !='') {
$GLOBALS['contentAs_arr'][($param_pageas)]=$param_array;
}
$foreachname="\$e" . call_my_md5($json);
$p=md5($json);
return "<?php	\$a{$p}=$json;  {$foreachname}=include(D_Get_Content_Mysql_Array(md5(print_r(\$a{$p},1)),\$a{$p})); \n   \$loop=0;    \n foreach( {$foreachname} as " . call_my_var(call_my_GetArray($param_array, 'as', 'vo')) . "  ){  \$loop++; ?>";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=str_replace(array('</content>', '{/content}'), '<?php } ?>', $this->intelligence_FileTemplatescContent);
foreach ($GLOBALS['contentAs_arr'] as $param_v) {
$this->intelligence_page_for($param_v);
}
}
function intelligence_page_for($param_jsonarr)
{
$GLOBALS['pageas']=call_my_var(call_my_GetArray($param_jsonarr, 'pageas', 'page'));
$GLOBALS['jsonarr']=$param_jsonarr;
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'/([{|<])page([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\']+)(}|\s+}|>|\s+>)/i',
function ($param_matches) {
$page_array=include $this->intelligence_GetContentPageMysqlArray($param_matches[1], $GLOBALS['jsonarr']);
$GLOBALS['page_array']=$page_array;
$param_array=call_my_GetDivArray($param_matches[0]);
$param_as=call_my_var(call_my_GetArray($param_array, 'as', 'vo'));
return "<?php   {$GLOBALS['pageas']}s=(int){$page_array['pages']} + 1; \n   for({$param_as}['number']=1; \n  {$param_as}['number'] < {$GLOBALS['pageas']}s; {$param_as}['number']={$param_as}['number'] + 1){ ?>";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace('#\{/page\}#', '<?php } ?>', $this->intelligence_FileTemplatescContent);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\{\\' . $GLOBALS['pageas'] . '\.([a-z_]+)\}#',
function ($param_matches) {
return $GLOBALS['page_array'][$param_matches[1]];
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#\\' . $GLOBALS['pageas'] . '\.([a-z_]+)#',
function ($param_matches) {
return $GLOBALS['page_array'][$param_matches[1]];
},
$this->intelligence_FileTemplatescContent
);
}
public static function intelligence_GetContentPageWhere($param_arr_json)
{
$param_soso_id=(int)call_my_GetArray($param_arr_json, 'searchid', '0');
$param_soso=call_my_GetArray($param_arr_json, 'search', '');
$param_seltree_select_nodeId=call_my_GetArray($param_arr_json, 'pid', '');
$param_hot=call_my_GetArray($param_arr_json, 'hot', '');
$param_where_sql="";
$param_template=call_my_GetArray($param_arr_json, 'template', '');
if ($param_template !='') {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_pid=call_my_str_replace('|', ',', $param_template);
$param_arr=explode(',', $param_pid);
$param_sql_in='';
$param_i=0;
foreach ($param_arr as $pram_v) {
$param_i++;
if ($pram_v !='') {
$param_sql_in .="'$pram_v'";
}
if ($param_i < count($param_arr)) {
$param_sql_in .=',';
}
}
$param_where_sql .=" `template` IN({$param_sql_in})  ";
}
if ($param_soso !='') {
$param_soso=call_my_str_replace('+', '', $param_soso);
if ($param_soso_id==1) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .="  ( `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' )";
} else if ($param_soso_id==2) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" `id`='$param_soso'  ";
} else if ($param_soso_id==3) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" `static_url`  REGEXP '$param_soso'  ";
} else if ($param_soso_id==4) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" ( `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}'  )";
} else if ($param_soso_id==5) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" ( `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}'  )";
} else if ($param_soso_id==6) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" ( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}'  )";
} else if ($param_soso_id==7) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" ( `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
} else {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" ( `seodescription`  REGEXP '{$param_soso}' or `eseodescription`  REGEXP '{$param_soso}' or  `seokeywords`  REGEXP '{$param_soso}' or `eseokeywords`  REGEXP '{$param_soso}' or  `content`  REGEXP '{$param_soso}' or `econtent`  REGEXP '{$param_soso}' or `name`  REGEXP '{$param_soso}' or `ename`  REGEXP '{$param_soso}' or  `attribute1`  REGEXP '{$param_soso}' or `eattribute1`  REGEXP '{$param_soso}' or `attribute2`  REGEXP '{$param_soso}' or `eattribute2`  REGEXP '{$param_soso}' or `attribute3`  REGEXP '{$param_soso}' or `eattribute3`  REGEXP '{$param_soso}' or `attribute4`  REGEXP '{$param_soso}' or `eattribute4`  REGEXP '{$param_soso}'  )";
}
}
if ($param_seltree_select_nodeId !='') {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_seltree_select_nodeId=call_my_str_replace(',', '|', $param_seltree_select_nodeId);
$param_where_sql .=" `pid`  REGEXP '{$param_seltree_select_nodeId}'  ";
}
if ($param_hot > 0) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" `hot`  !='0'  ";
}
$param_sdates=call_my_GetArray($param_arr_json, 'sdates', '0');
if ($param_sdates !='') {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" `sdates`='{$param_sdates}'  ";
}
$param_isgraph=call_my_GetArray($param_arr_json, 'isgraph', '0');
if ($param_isgraph !=0) {
if ($param_where_sql !='') {
$param_where_sql .=" AND ";
}
$param_where_sql .=" `graph`  !=''  ";
}
$param_where=call_my_GetArray($param_arr_json, 'where', '');
if (trim($param_where) !='') {
$param_where_is=call_my_strtolower(call_my_str_replace(' ', '', $param_where));
if (substr($param_where_is, 0, 2)=='or' or substr($param_where_is, 0, 3)=='and') {
$param_where_sql .="  {$param_where}  ";
} else {
$param_where_sql .="  and  {$param_where}  ";
}
}
if ($param_where_sql !='') {
$param_where_sql="WHERE" . $param_where_sql;
}
return $param_where_sql;
}
public function intelligence_GetContentPageMysqlArray($param_name, $param_arr_json)
{
$param_where_sql=templates::intelligence_GetContentPageWhere($param_arr_json);
$ColumnName='mysql_ColumnName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI'] . $param_where_sql);
$param_array=$this->GetFileArrayCodeCache($ColumnName);
if ($param_array==false or bs_lib::get_configs_value('personality', 'cache')==1) {
$param_rows=call_my_GetArray($param_arr_json, 'rows', '8');
if ($param_rows==0) {
$param_rows=10;
}
$param_sql="SELECT count(*)as 'hangshu' FROM `hdsys_content` " . $param_where_sql;
$param_db_array_value=$this->intelligence_db->intelligence_array($param_sql);
if (!$param_db_array_value) {
echo '<a style="color: #CC5522;" >[模版参数错误导致sql.错误:' . $param_sql . '] ' . time() . '<a>';
exit;
}
$param_tmp_rows=(int)$param_db_array_value['hangshu'];
$param_while_array_list_all['rows']=$param_tmp_rows;
$param_while_array_list_all['pages']=ceil($param_tmp_rows / $param_rows);
if (set_get('page')==0 or set_get('page')=='') {
$param_while_array_list_all['current']=1;
$param_while_array_list_all['prev']=1;
$param_while_array_list_all['next']=1;
if ($param_while_array_list_all['pages'] > 1) {
$param_while_array_list_all['next']=2;
}
} else {
$param_while_array_list_all['current']=set_get('page');
$param_while_array_list_all['prev']=$param_while_array_list_all['current'] - 1;
$param_while_array_list_all['next']=$param_while_array_list_all['current'] + 1;
if ($param_while_array_list_all['prev'] <=0) {
$param_while_array_list_all['upper']=1;
}
if ($param_while_array_list_all['next'] > $param_while_array_list_all['pages']) {
$param_while_array_list_all['next']=$param_while_array_list_all['pages'];
}
}
return $this->PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
} else {
return $param_array;
}
}
public static function intelligence_GetColumnMysqlArray($param_name, $param_arr_json)
{
$param_db=bs_lib::load_libhdsys_class("" . 'db');
$searchid=set_get('searchid');
$search=set_get('search');
$page=(int)set_get('page');
$param_log=(int)set_get('dbuglog');
if ($page > 0) {
$param_db_ID=$page - 1;
} else {
$param_db_ID=0;
$page=1;
}
$rows=$param_arr_json['rows'];
if ($rows==0) {
$rows=10;
}
$page_gegin=$param_db_ID * $rows;
$ColumnName='mysql_ColumnName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI']);
$param_array=templates::GetFileArrayCodeCache($ColumnName);
if ($param_array==false or bs_lib::get_configs_value('personality', 'cache')==1) {
if (trim($param_arr_json['where'])=='') {
$param_WHERE=" ";
} else {
$param_WHERE=" WHERE {$param_arr_json['where']} ";
}
$param_in_sql=' ';
$param_namearraylist=array();
if (isset($GLOBALS['data']['pid']) and $search=='') {
if ($GLOBALS['data']['pid']==0) {
$param_sql="SELECT * FROM `hdsys_list` WHERE  pid='{$GLOBALS['data']['id']}'  ";
if ($param_log==1) {
echo "<!" . "--$param_sql--" . ">";
}
$param_db_array_value=$param_db->intelligence_query($param_sql);
$param_while_array_list_all='';
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_while_array_list_all .=$param_value['id'] . ',';
}
if ($param_while_array_list_all !='') {
$param_in=$param_while_array_list_all . '-1';
if ($param_WHERE=='') {
$param_in_sql=" WHERE pid in($param_in)";
} else {
if (isset($param_arr_json['current'])) {
$param_in_sql=" AND pid in($param_in)";
} else {
$param_in_sql=" or pid in($param_in)";
}
}
}
}
}
$param_namearraylist=include(templates::intelligence_ClassificationlArray('all', -1));
$param_while_array_list_all=array();
if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
}
if (isset($param_arr_json['by'])) {
if ($param_arr_json['by']=='') {
$param_arr_json['by']='sort';
}
} else {
$param_arr_json['by']='sort';
}
$GLOBALS['jsonarr']['where']="{$param_WHERE} {$param_in_sql}";
$param_sql="SELECT * FROM `hdsys_{$param_arr_json['table']}` {$param_WHERE} {$param_in_sql} ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$page_gegin},{$rows}";
if ($param_log==1) {
echo "<!" . "--$param_sql--" . ">";
}
$param_db_array_value=$param_db->intelligence_query($param_sql);
if (!$param_db_array_value) {
echo '<a style="color: #CC5522;" >[模版参数错误导致.sql错误:' . $param_sql . '] ' . time() . '<a>';
exit;
}
$param_i=0;
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_i++;
$param_pid_arr=explode(',', $param_value['pid']);
$param_pid_obj=array();
krsort($param_pid_arr);
foreach ($param_pid_arr as $param_v) {
if (isset($param_namearraylist[$param_v])) {
$param_namearraylist[$param_v]['id']=$param_v;
$param_pid_obj[]=$param_namearraylist[$param_v];
}
}
$param_value['nav']=$param_pid_obj;
if (!isset($param_value['nav'][0])) {
$param_value['nav'][0]=array('elistname'=> 'No List', 'listname'=> '未分类', 'static_url'=> '', 'pid'=> '');
}
$param_value['i']=$param_i;
$param_while_array_list_all[]=$param_value;
}
return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
} else {
return $param_array;
}
}
public static function intelligence_GetContentMysqlArray($param_name, $param_arr_json)
{
$param_db=bs_lib::load_libhdsys_class("" . 'db');
$param_where_sql=templates::intelligence_GetContentPageWhere($param_arr_json);
$ColumnName='mysql_ContenName_' . $param_name . '_' . md5($_SERVER['REQUEST_URI'] . $param_where_sql);
$param_array=templates::GetFileArrayCodeCache($ColumnName);
if ($param_array==false or bs_lib::get_configs_value('personality', 'cache')==1) {
$param_page=call_my_GetArray($param_arr_json, 'page', '0');
$param_log=(int)set_get('dbuglog');
if ($param_page > 0) {
$param_db_ID=$param_page - 1;
} else {
$param_db_ID=0;
}
$param_begin=call_my_GetArray($param_arr_json, 'begin', '0');
$param_rows=call_my_GetArray($param_arr_json, 'rows', '8');
if ($param_rows==0) {
$param_rows=10;
}
$page_gegin=$param_begin + $param_db_ID * $param_rows;
$param_namearraylist=array();
$param_namearraylist=include(templates::intelligence_ClassificationlArray('all', -1));
$param_while_array_list_all=array();
$param_by=call_my_GetArray($param_arr_json, 'by', 'add_time');
$param_sort=call_my_GetArray($param_arr_json, 'sort', 'DESC');
$param_sql="SELECT * FROM `hdsys_content` {$param_where_sql} ORDER BY `{$param_by}` {$param_sort}  LIMIT {$page_gegin},{$param_rows}";
if ($param_log==1) {
echo "<!" . "--$param_sql--" . ">";
}
$param_db_array_value=$param_db->intelligence_query($param_sql);
if (!$param_db_array_value) {
echo '<a style="color: #CC5522;" >[模版参数错误导致.sql错误:' . $param_sql . '] ' . time() . '<a>';
exit;
}
$param_i=0;
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_i++;
$param_value['sql']=$param_sql;
if (isset($param_namearraylist[$param_value['pid']])) {
$param_value['listname']=$param_namearraylist[$param_value['pid']]['listname'];
$param_value['elistname']=$param_namearraylist[$param_value['pid']]['elistname'];
$param_value['liststatic_url']=$param_namearraylist[$param_value['pid']]['static_url'];
} else {
$param_value['elistname']='No List';
$param_value['listname']='未分类';
$param_value['liststatic_url']='#';
}
$param_value['modules']=json_decode($param_value['modules'], 1);
$param_value['emodules']=json_decode($param_value['emodules'], 1);
$param_value['i']=$param_i;
$param_while_array_list_all[]=$param_value;
}
return templates::PushFileArrayCodeCache($ColumnName, $param_while_array_list_all);
} else {
return $param_array;
}
}
public static function intelligence_ClassificationlArray($param_name, $param_arr_json)
{
$param_array=templates::GetFileArrayCodeCache('mysql_Classi_ficati_onlArray_' . $param_name);
if ($param_array==false or bs_lib::get_configs_value('personality', 'cache')==1) {
$param_db=bs_lib::load_libhdsys_class("" . 'db');
$param_sql="SELECT * FROM `hdsys_list`   ";
$param_db_array_value=$param_db->intelligence_query($param_sql);
$param_while_array_list_all='';
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_namearraylist[$param_value['id']]=array('listname'=> $param_value['name'], 'elistname'=> $param_value['ename'], 'name'=> $param_value['name'], 'ename'=> $param_value['ename'], 'static_url'=> $param_value['static_url'], 'pid'=> $param_value['pid']);
}
return templates::PushFileArrayCodeCache('mysql_Classi_ficati_onlArray_' . $param_name, $param_namearraylist);
} else {
return $param_array;
}
}
public function intelligence_advertisementAs()
{
$this->intelligence_FileTemplatescContent=preg_replace_callback(
'#([{|<])advertisement([[a-z_\s]+)=([0-9]+|[a-zA -Z0-9_]+|\"(.*?)\"|\'.*?\'])+(}|\s+}|>|\s+>)#',
function ($param_matches) {
$param_array=call_my_GetDivArray($param_matches[0]);
$param_filename=call_my_GetArray($param_array, 'filename', '');
$param_File_dir=$this->intelligence_getadvertisementArray($param_filename);
$param_for_val=call_my_var('a' . call_my_var(time()));
$param_as=call_my_var(call_my_GetArray($param_array, 'as', 'vo'));
return "<?php   {$param_for_val}=include('{$param_File_dir}');  \n   \$loop=0;    \n foreach( {$param_for_val} as {$param_as}  ){ \$loop++; ?>";
},
$this->intelligence_FileTemplatescContent
);
$this->intelligence_FileTemplatescContent=preg_replace('#\{/advertisement\}#', '<?php } ?>', $this->intelligence_FileTemplatescContent);
}
public static function intelligence_GetExhibitionMysqlArray($param_name, $param_arr_json)
{
$param_array=templates::GetFileArrayCodeCache('mysql_Exhibition_' . $param_name);
if ($param_array==false or bs_lib::get_configs_value('personality', 'cache')==1) {
$param_arr_json['where']=call_my_GetArray($param_arr_json, 'where', '');
$param_arr_json['by']=call_my_GetArray($param_arr_json, 'by', 'sort');
$param_arr_json['sort']=call_my_GetArray($param_arr_json, 'sort', 'sort');
$param_arr_json['begin']=call_my_GetArray($param_arr_json, 'begin', '0');
$param_arr_json['rows']=call_my_GetArray($param_arr_json, 'rows', '10');
$param_arr_json['table']=call_my_GetArray($param_arr_json, 'table', '');
$param_db=bs_lib::load_libhdsys_class("" . 'db');
if (trim($param_arr_json['where'])=='') {
$param_WHERE=" ";
} else {
$param_WHERE=" WHERE {$param_arr_json['where']} ";
}
if (isset($param_arr_json['by'])) {
if ($param_arr_json['by']=='') {
$param_arr_json['by']='sort';
}
} else {
$param_arr_json['by']='sort';
}
$random_sql="";
if (isset($param_arr_json['random'])) {
if ($param_arr_json['random']==false) {
$random_sql="";
} else {
$random_sql=" ORDER BY RAND() ";
}
} else {
$random_sql="";
}
if ($param_arr_json['rows']==0) {
$param_arr_json['rows']=8;
}
$param_while_array_list_all=array();
if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
echo '<a style="color: #CC5522;" >[exhibition标签 table参数数据表不存在~错误:' . $param_arr_json['table'] . '] ' . call_my_time() . '<a>';
return templates::PushFileArrayCodeCache('mysql_Exhibition_' . $param_name, $param_while_array_list_all);
}
if ($random_sql=='') {
$param_sql="SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}    ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$param_arr_json['begin']},{$param_arr_json['rows']}";
} else {
$param_sql="SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}  {$random_sql}    LIMIT {$param_arr_json['rows']}";
}
$param_db_array_value=$param_db->intelligence_query($param_sql);
if (!$param_db_array_value) {
echo '<a style="color: #CC5522;" >[模版参数错误导致sql~错误:' . $param_sql . '] ' . call_my_time() . '<a>';
exit;
}
$param_namearraylist=include(templates::intelligence_ClassificationlArray('all', -1));
$param_i=0;
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_i++;
$param_value['i']=$param_i;
if (isset($param_value['pid'])) {
if (isset($param_namearraylist[$param_value['pid']])) {
$param_value['listname']=$param_namearraylist[$param_value['pid']]['listname'];
$param_value['elistname']=$param_namearraylist[$param_value['pid']]['elistname'];
$param_value['liststatic_url']=$param_namearraylist[$param_value['pid']]['static_url'];
} else {
$param_value['elistname']='No List';
$param_value['listname']='未分类';
$param_value['liststatic_url']='#';
}
}
$param_while_array_list_all[]=$param_value;
}
return templates::PushFileArrayCodeCache('mysql_Exhibition_' . $param_name, $param_while_array_list_all);
} else {
return $param_array;
}
}
public static function intelligence_GetExQueryMysqlArray($param_name, $param_arr_json)
{
$param_array=templates::GetFileArrayCodeCache('mysql_GetExQuery_' . $param_name);
if ($param_array==false) {
$param_db=bs_lib::load_libhdsys_class("" . 'db');
if (!isset($param_arr_json['where']) or trim($param_arr_json['where'])=='') {
$param_WHERE=" ";
} else {
$param_WHERE=" WHERE {$param_arr_json['where']} ";
}
if (isset($param_arr_json['by'])) {
if ($param_arr_json['by']=='') {
$param_arr_json['by']='sort';
}
} else {
$param_arr_json['by']='sort';
}
$random_sql="";
if (isset($param_arr_json['random'])) {
if ($param_arr_json['random']==false) {
$random_sql="";
} else {
$random_sql=" ORDER BY RAND() ";
}
} else {
$random_sql="";
}
$param_arr_json['rows']=call_my_GetArray($param_arr_json, 'rows', '1');
if ($param_arr_json['rows']==0) {
$param_arr_json['rows']=1;
}
if (!isset($param_arr_json['table'])) {
$param_arr_json['table']='';
}
$param_while_array_list_all=array();
if (!$param_db->intelligence_is_table('hdsys_' . $param_arr_json['table'])) {
echo '<a style="color: #CC5522;" >[exquery标签 table参数数据表不存在~错误:' . $param_arr_json['table'] . '] ' . call_my_time() . '<a>';
return templates::PushFileArrayCodeCache('mysql_GetExQuery_' . $param_name, $param_while_array_list_all);
}
if ($random_sql=='') {
$param_sql="SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}    ORDER BY `{$param_arr_json['by']}` {$param_arr_json['sort']}  LIMIT {$param_arr_json['begin']},{$param_arr_json['rows']}";
} else {
$param_sql="SELECT * FROM `hdsys_{$param_arr_json['table']}`    {$param_WHERE}  {$random_sql}    LIMIT {$param_arr_json['rows']}";
}
$param_db_array_value=$param_db->intelligence_query($param_sql);
if (!$param_db_array_value) {
echo '<a style="color: #CC5522;" >[模版参数错误导致sql~错误:' . $param_sql . '] ' . call_my_time() . '<a>';
exit;
}
$param_i=0;
while ($param_value=$param_db->intelligence_assoc($param_db_array_value)) {
$param_i++;
$param_value['i']=$param_i;
$param_while_array_list_all[]=$param_value;
}
if ($param_arr_json['rows']==1) {
if (isset($param_while_array_list_all[0])) {
$param_while_array_list_all=$param_while_array_list_all[0];
}
}
return templates::PushFileArrayCodeCache('mysql_GetExQuery_' . $param_name, $param_while_array_list_all);
} else {
return $param_array;
}
}
public function intelligence_getadvertisementArray($param_name)
{
$param_array=$this->GetFileArrayCodeCache('Advertisement_' . $param_name);
if ($param_array==false) {
$param_File=HDSYS_DIR_SYS . 'templates/' . $this->intelligence_templates_dir . '/modular/' . $param_name . '.*.modular.php';
$param_File_ARRAY=glob($param_File);
$param_while_array_list_all=array();
foreach ($param_File_ARRAY as $param_filename) {
if (file_exists($param_filename)) {
$param_arr=include($param_filename);
if (isset($param_arr['name']) && isset($param_arr['code'])) {
$param_val=$param_arr['imges'];
$param_val=str_replace('{__URL__}', getsysurl(), $param_val);
$param_arr['imges']=str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);
$param_val=$param_arr['eimges'];
$param_val=str_replace('{__URL__}', getsysurl(), $param_val);
$param_arr['eimges']=str_replace('{__TEMPLATES__}',  intelligence_get_templates_dir(), $param_val);
$param_while_array_list_all[]=$param_arr;
}
}
}
return $this->PushFileArrayCodeCache('Advertisement_' . $param_name, $param_while_array_list_all);
} else {
return $param_array;
}
}
public function GetListArray($param_pid)
{
$param_sql="SELECT * FROM`hdsys_list`WHERE sdates=0 and `pid`='{$param_pid}'   ORDER BY`sort`ASC LIMIT 1000";
$param_db_array_value=$this->intelligence_db->intelligence_query($param_sql);
$param_while_array_list_all=array();
while ($param_value=$this->intelligence_db->intelligence_assoc($param_db_array_value)) {
$param_children=$this->GetListArray($param_value['id']);
if (count($param_children) > 0) {
$param_value['data']=$param_children;
}
$param_while_array_list_all[]=$param_value;
}
return $param_while_array_list_all;
}
public function intelligence_GetListArrayPid($param_pid, $pram_name)
{
$param_pid=call_my_str_replace('|', ',', $param_pid);
$param_arr=explode(',', $param_pid);
$param_sql_in='';
$param_i=0;
foreach ($param_arr as $pram_v) {
$param_i++;
if ($pram_v !='') {
$param_sql_in .="'$pram_v'";
}
if ($param_i < count($param_arr)) {
$param_sql_in .=',';
}
}
$param_sql="SELECT * FROM`hdsys_list`WHERE `sdates`=0 AND `{$pram_name}` IN({$param_sql_in}) ORDER BY`sort`ASC LIMIT 1000";
$param_db_array_value=$this->intelligence_db->intelligence_query($param_sql);
$param_while_array_list_all=array();
while ($param_value=$this->intelligence_db->intelligence_assoc($param_db_array_value)) {
$param_children=$this->GetListArray($param_value['id']);
if (count($param_children) > 0) {
$param_value['data']=$param_children;
}
$param_while_array_list_all[]=$param_value;
}
return $param_while_array_list_all;
}
public function intelligence_GetListArrayParent($param_pid)
{
$param_pid=call_my_str_replace('|', ',', $param_pid);
$param_arr=explode(',', $param_pid);
$param_sql_in='';
$param_i=0;
foreach ($param_arr as $pram_v) {
$param_i++;
if ($pram_v !='') {
$param_sql_in .="'$pram_v'";
}
if ($param_i < count($param_arr)) {
$param_sql_in .=',';
}
}
$param_sql="SELECT id,pid FROM`hdsys_list` WHERE  `id`in ({$param_sql_in})  LIMIT 1";
$param_db_array=$this->intelligence_db->intelligence_array($param_sql);
if (!$param_db_array) {
$param_db_array['pid']=0;
}
$param_sql="SELECT * FROM`hdsys_list`WHERE   sdates=0 and(pid='{$param_pid}'   or pid='{$param_db_array['pid']}' and pid !=0 ) ORDER BY`sort`ASC LIMIT 1000";
$param_db_array_value=$this->intelligence_db->intelligence_query($param_sql);
$param_while_array_list_all=array();
while ($param_value=$this->intelligence_db->intelligence_assoc($param_db_array_value)) {
$param_children=$this->GetListArray($param_value['id']);
if (count($param_children) > 0) {
$param_value['data']=$param_children;
}
$param_while_array_list_all[]=$param_value;
}
return $param_while_array_list_all;
}
public function GetnavigationCacheArray($param_array)
{
$param_parent=call_my_GetArray($param_array, 'parent', '0');
$param_pid=call_my_GetArray($param_array, 'pid', '');
$param_id=call_my_GetArray($param_array, 'id', '');
$param_template=call_my_GetArray($param_array, 'template', '');
$param_key='mysql_navigation_' . md5($param_parent . $param_pid . $param_template);
$param_array=$this->GetFileArrayCodeCache($param_key);
if ($param_array==false) {
$param_while_array_list_all=array();
if ($param_template !='' and count($param_while_array_list_all)==0) {
$param_while_array_list_all=$this->intelligence_GetListArrayPid($param_template, 'template');
}
if ($param_id !='' and count($param_while_array_list_all)==0) {
$param_while_array_list_all=$this->intelligence_GetListArrayPid($param_pid, 'id');
}
if ($param_pid !='' and count($param_while_array_list_all)==0) {
$param_while_array_list_all=$this->intelligence_GetListArrayPid($param_pid, 'pid');
}
if ($param_parent !='' and count($param_while_array_list_all)==0) {
$param_while_array_list_all=$this->intelligence_GetListArrayParent($param_parent);
}
if (count($param_while_array_list_all)==0) {
$param_while_array_list_all=$this->GetListArray(0);
}
return $this->PushFileArrayCodeCache($param_key, $param_while_array_list_all);
} else {
return $param_array;
}
}
public static function PushFileArrayCodeCache($param_filename, $param_array)
{
$param_code_array_php=ArrayToCodeFile($param_array);
$param_File=HDSYS_DIR_SYS . 'cache/configs/' . $param_filename . '.config.php';
$param_tmp=file_put_contents($param_File, $param_code_array_php);
return $param_File;
}
public static function GetFileArrayCodeCache($param_filename)
{
$param_File=HDSYS_DIR_SYS . 'cache/configs/' . $param_filename . '.config.php';
if (file_exists($param_File)) {
return $param_File;
} else {
return false;
}
}
public function GetTemplatesName($param_PATH_INFO='')
{
$param_arrars=GetNameAndLang($param_PATH_INFO);
if ($param_arrars['templates'] !='') {
return  $param_arrars;
}
$param_static_url=$param_arrars['name'];
$param_route='mysql_route_' . call_my_md5($param_static_url);
$param_array=$this->GetFileArrayCodeCache($param_route);
if ($param_array==true) {
return include($param_array);
}
$param_sql="SELECT * FROM`hdsys_list`WHERE `static_url`='{$param_static_url}'  LIMIT 1";
$param_db_array=$this->intelligence_db->intelligence_array($param_sql);
if ($param_db_array) {
$param_arrars['templates']='list.' . $param_db_array['template'];
$param_arrars['array']=$param_db_array;
$param_arrars['weizhi']='hdsys_list';
$this->PushFileArrayCodeCache($param_route, $param_arrars);
return $param_arrars;
}
$param_sql="SELECT * FROM`hdsys_content`WHERE `static_url`='{$param_static_url}' LIMIT 1";
$param_db_array=$this->intelligence_db->intelligence_array($param_sql);
if ($param_db_array) {
$param_db_array['modules']=json_decode($param_db_array['modules'], 1);
$param_db_array['emodules']=json_decode($param_db_array['emodules'], 1);
#多加分类.
$param_namearraylist=include(templates::intelligence_ClassificationlArray('all', -1));
$param_pid_arr=explode(',', $param_db_array['pid']);
$param_pid_obj=array();
krsort($param_pid_arr);
foreach ($param_pid_arr as $param_v) {
if (isset($param_namearraylist[$param_v])) {
$param_namearraylist[$param_v]['id']=$param_v;
$param_pid_obj[]=$param_namearraylist[$param_v];
}
}
$param_db_array['nav']=$param_pid_obj;
$param_arrars['templates']='content.' . $param_db_array['template'];
$param_arrars['array']=$param_db_array;
$param_arrars['weizhi']='hdsys_content';
$this->PushFileArrayCodeCache($param_route, $param_arrars);
return $param_arrars;
}
$param_arrars['templates']=$param_static_url;
$param_arrars['array']=array('id'=> 0, 'pid'=> 0);;
$param_arrars['weizhi']='oths';
$this->PushFileArrayCodeCache($param_route, $param_arrars);
return $param_arrars;
}
}
